<?php require_once('../../core/import.php');?>
<?php User::Permission('ACCOUNT_LICENCE_ADD'); ?>
<?php
    if($_SERVER['REQUEST_METHOD']=='POST')
    {
        #图片处理
        $Result=Upload::Probe($_FILES['PicturePath'],Config::UPLOAD_ATTACHMENT_SIZE_IMAGE,Config::UPLOAD_ATTACHMENT_EXT_IMAGE,Config::PATH_UPLOAD_ATTACHMENT_TEMP);

        $FileName='';
        switch($Result['error'])
        {
            case UPLOAD_ERR_OK:
                $FileName=Upload::Execute($_FILES['PicturePath'],Config::PATH_UPLOAD_ATTACHMENT_TEMP);
            break;
            case UPLOAD_ERR_NO_FILE:                
                exit('{"Number":"1","Description":"请上传证书"}');
            break;
            case Upload::UPLOAD_ERR_CUSTOM_EXT:
                exit('{"Number":"2","Description":"证书格式不正确，只能是：'.join(',',Upload::$UPLOAD_EXT_IMAGE).'。"}');
            break;
            case Upload::UPLOAD_ERR_CUSTOM_SIZE:
                exit('{"Number":"3","Description":"证书大小超过了限制，不能超过：'.Functions::SizeFormat(Config::UPLOAD_ATTACHMENT_SIZE_IMAGE).'。"}');
            break;
            default :
                exit('{"Number":"4","Description":"证书上传失败。错误代码：'.$Result['error'].'，错误描述：'.$Result['message'].'。"}');
        }

        #上传数据
        DB::Insert('licence',array
		(
			'Account'=>Functions::FormArgs('Account'),
			'Name'=>Functions::FormArgs('Name'),
			'Authority'=>Functions::FormArgs('Authority'),
			'PicturePath'=>Functions::FormArgs('PicturePath'),
			'Datetime'=>date('Y-m-d G:i:s'),
           	'PicturePath'=>$FileName
		));
		//信息统计
		User::Statistics_User('ACCOUNT_LICENCE_ADD','licence','会员版块');
		echo '{"Number":"0","Description":"发布成功"}';
    }
?>